package StudyCode.summary.mydatetime;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.Month;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class UsingDateTime {
	public static void main(String[] args) {
		LocalDate ld = LocalDate.of(1986, Month.MAY, 11);
		LocalTime lt = LocalTime.of(8, 6, 6);
		System.out.println("ld: " + ld);
		System.out.println("ld 是闰年吗？: " + ld.isLeapYear());
		System.out.println("lt: " + lt);
		// 创建个 LocalDateTime 对象通过 LocalDate 跟 LocalTime
		LocalDateTime ldt = LocalDateTime.of(ld, lt);
		System.out.println("ldt: " + ldt);

		// LocalDateTime 加两个月25分钟
		LocalDateTime ldt2 = ldt.plusMonths(2).plusMinutes(25);
		System.out.println("ldt2: " + ldt2);

		// 输出来自于  LocalDateTime 对象的 LocalDate 跟 LocalTime对象
		LocalDate ld2 = LocalDate.from(ldt2);
		LocalTime lt2 = LocalTime.from(ldt2);
		System.out.println("ld2: " + ld2);
		System.out.println("lt2: " + lt2);
	}
}
